/*
 * @Description: 
 * @version: 
 * @Author: 171
 * @Date: 2022-08-31 10:29:55
 * @LastEditors: 171
 * @LastEditTime: 2022-09-05 11:35:48
 */
import { defineStore } from 'pinia'
import { NAMES } from './name-space'
import { getApiList } from '../server'
import type { RootObject, Children, ChinaAdd, ChinaTotal, LocalCityNCOVDataList } from './type'


export const useListStore = defineStore(NAMES.LIST, {
  state: () => ({
    list: <RootObject> {},
    items: <Children[]> [],
    chinaAdd: <ChinaAdd> {},
    chinaTotal: <ChinaTotal> {},
    cityDetail: <LocalCityNCOVDataList[]>[]
  }),
  actions: {
    async getList(){     
      const result = await getApiList();
      this.list = result.data;
      this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd;
      this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal;
      this.cityDetail = this.list.localCityNCOVDataList.slice(0, 10);
    }
  }
  
})
